import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public final class ch extends g {

    public static final ch f = new ch(0);
    public int g;
    public g h;
    public u i;
    public bs j;

    public ch(int k) {
        g = k;
    }

    public final void a(ba ba1, o o1, Graphics g1, int k, int l) {
        switch (g) {
            case 0:

                break;
            case 1:
                g g2 = h;
                k--;
                l--;
                g1.setColor(g2.d);
                for (int i1 = super.d - 1; i1 >= 0; i1--)
                    g1.drawLine(i1, i1, k - i1, i1);

                g1.setColor(g2.c);
                for (int j1 = super.c - 1; j1 >= 0; j1--)
                    g1.drawLine(k - j1, j1, k - j1, l - j1);

                g1.setColor(g2.e);
                for (int k1 = super.e - 1; k1 >= 0; k1--)
                    g1.drawLine(k1, l - k1, k - k1, l - k1);

                g1.setColor(g2.b);
                for (int l1 = super.b - 1; l1 >= 0; l1--)
                    g1.drawLine(l1, l1, l1, l - l1);

                return;
            case 2:
                a(g1, i, ((g) (this)), k, l);
                return;
            case 3:
                bb bb1 = bb.b();

                try {
                    bb1.a(1, ba1);
                    bb1.a(2, g1);
                    bb1.a(3, o1);
                    bb1.a(4, k);
                    bb1.a(5, l);
                    bb1.a(j);
                    bb1.c();
                } catch (Exception e1) {
                    bb1.c();
                }
        }
    }

    public static boolean a(Graphics g1, u u1, g g2, int k, int l) {
        int i1;
        int j1;
        int k1;
        int l1;
        int i2;
        int j2;
        int k2;
        int l2 = 0;
        int i3 = 0;
        Image image = u1.a;
        i1 = (image).getWidth();
        j1 = image.getHeight();
        k1 = g2.d;
        l1 = g2.c;
        i2 = g2.e;
        j2  = g2.b;
        if ((j2) + l1 >= i1 || k1 + i2 >= j1)
            return false;
        if (j2 > 0) {
            if (k1 > 0)
                g1.drawRegion(image, 0, 0, j2, k1, 0, 0, 0, 20);
            if (i2 > 0)
                g1.drawRegion(image, 0, j1 - i2, j2, i2, 0, 0, l - i2, 20);
        }
        if (l1 > 0) {
            if (k1 > 0)
                g1.drawRegion(image, i1 - l1, 0, l1, k1, 0, k - l1, 0, 20);
            if (i2 > 0)
                g1.drawRegion(image, i1 - l1, j1 - i2, l1, i2, 0, k - l1, l - i2, 20);
        }
        k2  = k - j2 - l1;
        if (k2 > 0) {
            l2 = i1 - j2 - l1;
            i3 = j2;
        }
        int j3;
        while (k2 > 0) {
            j3 = l2 >= k2 ? k2 : l2;
            if (k1 > 0)
                g1.drawRegion(image, j2, 0, j3, k1, 0, i3, 0, 20);
            if (i2 > 0)
                g1.drawRegion(image, j2, j1 - i2, j3, i2, 0, i3, l - i2, 20);
            k2 -= j3;
            i3 = i3 + j3;
        }
            k2 = l - k1 - i2;
        if ((k2) > 0) {
            l2 = j1 - k1 - i2;
        i3 = k1;
    }
        while (k2 > 0) {
            j3 = l2 >= k2 ? k2 : l2;
            if (j2 > 0)
                g1.drawRegion(image, 0, k1, j2, j3, 0, 0, i3, 20);
            if (l1 > 0)
                g1.drawRegion(image, i1 - l1, k1, l1, j3, 0, k - l1, i3, 20);
            k2 -= j3;
            i3 = i3 + j3;
        }
        return true;
    }

}